#ifndef SERVER_H_
#define SERVER_H_

#include <stdlib.h>
#include <stdio.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include "basic_types.h"

#define	DEFAULT_PORT	8000

typedef sockaddr_in	SOCKADDR;
typedef void (*fpCallback)(void *pData);

typedef struct _client
{
	int			nFD;		//socket描述符
	SOCKADDR	addr;		//客户端地址信息
}ClientInfo;

class Server;

class Server
{
public:
	Server();
	~Server();
	
public:
	int StartServer(uint32 nPort = DEFAULT_PORT);		//开始服务
	int StopServer();									//停止服务
	int	PostData(void *pData);							//
	
	void Reg_Recv(fpCallback _callback);
	void Reg_Status(fpCallback _callback);
	void Reg_Client(fpCallback _callback);
	
private:
	fpCallback	m_fpRecv;
	fpCallback	m_fpStatus;
	fpCallback	m_fpClient;
	
private:
	int32	m_fdServer;
	
};

#endif